package com.vegetable.modules.service.baseData.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.vegetable.common.utils.PageUtils;
import com.vegetable.common.utils.Query;
import com.vegetable.modules.entity.baseData.BaseCommodity;
import com.vegetable.modules.mapper.baseData.BaseCommodityMapper;
import com.vegetable.modules.service.baseData.IBaseCommodityService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 * 基础商品 服务实现类
 * </p>
 *
 * @author wangruijie
 * @since 2024-03-04
 */
@Slf4j
@Service
@AllArgsConstructor
public class BaseCommodityServiceImpl extends ServiceImpl<BaseCommodityMapper, BaseCommodity> implements IBaseCommodityService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String name = (String)params.get("name");
        IPage<BaseCommodity> page = this.page(
                new Query<BaseCommodity>().getPage(params),
                new QueryWrapper<BaseCommodity>()
                        .like(StringUtils.isNotBlank(name),"name", name)
        );

        return new PageUtils(page);
    }
}
